<?php

/*
	Class: DealersViewCountriesInUse

	About: Author
		Rich Joslin

	About: License
		<http://communit.as/docs/license>

	About: See Also
		- <Cts_Db_Table_Abstract>
*/
class DealersViewCountriesInUse extends Cts_Db_Table_Abstract {

	/* Group: Instance Variables */

	/*
		Variable: $_name
	*/
	protected $_name = 'dealers_vw_countries_in_use';

	/*
		Variable: $_primary
	*/
	protected $_primary = 'country_code';

	/* Group: Instance Methods */

	/*
		Function: getOptionsArray

		Arguments:
			first_option - A string that gets placed as the first option with no value.

		Returns: array of countries or an empty array
	*/
	function getOptionsArray($first_option = null) {
		$tmp_countries = $this->fetchAll();
		if (!is_null($tmp_countries)) {
			$tmp_countries = $tmp_countries->toArray();
			$countries = array();
			if (!is_null($first_option)) {
				$countries[''] = $first_option;
			}
			foreach ($tmp_countries as $country) {
				$countries[$country['country_code']] = $country['country'];
			}
			return $countries;
		} else {
			return array();
		}
	}

}
